﻿@model IEnumerable<HPIT_MVC.ViewModel.StudentViewModel>
@section Scripts
{
    <script>
        function deleteStudent(id) {
            if (confirm("您确认要删除吗？")) {
                $.post("@Url.Action("Delete","Student")", { sid: id }, function (data) {
                    if (data.Success) {
                        location.reload();
                    } else {
                        alert(data.Error);
                    }
                }, "json");
            }
        }
    </script>
    }
@{
    ViewBag.Title = "Index";
}


<h2>学生信息</h2>


<table class="table">
    <tr>
        <th>
            @Html.DisplayNameFor(model => model.StudentID)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.StudentName)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Sex)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.StudentAddress)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Mobile)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.ClassName)
        </th>
        <th></th>
    </tr>

    @foreach (var item in Model)
    {
        <tr>
            <td>
                @Html.DisplayFor(modelItem => item.StudentID)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.StudentName)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Sex)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.StudentAddress)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Mobile)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.ClassName)
            </td>
            <td>
                <div class="btn-group">
                    <a href="@Url.Action("Edit","Student",new {id=item.StudentID })"
                       class="btn btn-warning" style="margin-right:10px">修改</a>
                    <a href="@Url.Action("Details","Student",new {id=item.StudentID })"
                       class="btn btn-info" style="margin-right:10px">详情</a>
                    <a href="javascript:;"
                       class="btn btn-danger" onclick="deleteStudent(@item.StudentID)" style="margin-right:10px">删除</a>
                </div>
                @*@Html.ActionLink("Edit", "Edit", new { /* id=item.PrimaryKey */ }) |
                    @Html.ActionLink("Details", "Details", new { /* id=item.PrimaryKey */ }) |
                    @Html.ActionLink("Delete", "Delete", new { /* id=item.PrimaryKey */ })*@
            </td>
        </tr>
    }

</table>
<a href="@Url.Action("Add","Student")" class="btn btn-success">添加</a>
